package com.c.ctgproject.adapter.storage

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.entity.storage.StorageMaterialOutEntity
import com.c.ctgproject.mode.MyConstants
import com.c.ctgproject.ui.storage.material.StorageMaterialOutDetailActivity
import org.jetbrains.anko.startActivity

/**
 *作者:LiBW
 *创建日期: 2020/9/11
 *描述:仓储 物料出库adapter
 */
class StorageMaterialOutAdapter(private val context: Context, private val mList: List<StorageMaterialOutEntity.DataBean.ListBean>) : RecyclerView.Adapter<StorageMaterialOutAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_storage_material_out_list, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data = mList[position]
        holder.mOrderIdTV.text = data.materialSalesNo.toString()
        holder.mTimeTV.text = data.auditTime.toString()
        holder.mMaterialNameTV.text = data.materialName.toString()
        //详情
        holder.mItemLL.setOnClickListener {
            context.startActivity<StorageMaterialOutDetailActivity>(MyConstants.ENTITY to data)
        }
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val mOrderIdTV: TextView = itemView.findViewById(R.id.mOrderIdTV)
        val mTimeTV: TextView = itemView.findViewById(R.id.mTimeTV)
        val mMaterialNameTV: TextView = itemView.findViewById(R.id.mMaterialNameTV)
        val mItemLL: CardView = itemView.findViewById(R.id.mItemLL)


    }


}